<?php

namespace app\admin\validate\goods;

use think\Validate;

class BiaobenRongqi extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'title'  => 'require|unique:biaoben_rongqi,title',
    ];
    /**
     * 提示消息
     */
    protected $message = [
        'title.require' => '标题不能为空',
        'title.unique'  => '标题已存在',
    ];
    /**
     * 验证场景
     */
    protected $scene = [
        'add'  => ['title'],
        'edit' => ['title'],
    ];

    public function __construct(array $rule = [], array $message = [], array $field = [])
    {
        parent::__construct($rule, $message, $field);
        $ids = request()->param("ids");
        if ($ids) {
            $this->rule['title'] = 'require|unique:biaoben_rongqi,title,' . $ids . ',id';
        }
    }
    
}
